package com.qingfeng.provide.controller;

import com.qingfeng.core.data.ResultData;
import com.qingfeng.provide.service.ComplainService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @description: 投诉
 * @author:LWY
 * @date: 2017/11/15 16:05
 * @modified:
 */
@RestController
@RequestMapping("/complain")
public class ComplainController {
    @Autowired
    ComplainService complainService;

    @RequestMapping(value = "/", method = RequestMethod.POST)
    public ResultData submit(HttpServletRequest request) {
        List<MultipartFile> files = ((MultipartHttpServletRequest) request).getFiles("file");

        //用户id
        String user_id = request.getParameter("id");
        //任务id
        String task_id = request.getParameter("task_id");
        //投诉类型
        String type = request.getParameter("type");
        //投诉信息
        String message = request.getParameter("message");

        complainService.submit(user_id, task_id, type, message, files);
        ResultData resultData = new ResultData(ResultData.SUCCESS, "您的投诉已经提交成功,我们会尽快处理您的投诉,请耐心等待", "");
        return resultData;
    }
}
